<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">-->
<title>字典编辑</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, dic-scalable=no">

<!-- Basic Styles -->
<link rel="stylesheet"
	href="${ctx}/static/bootstrap/css/font-awesome.min.css">
<link rel="stylesheet" href="${ctx}/static/css/layout.css">
<link rel="stylesheet" href="${ctx}/static/css/groups.css">
<link rel="stylesheet" href="${ctx}/static/css/number.css">
<link rel="stylesheet" href="${ctx}/static/css/layer/layer.css">
<link rel="stylesheet"
	href="${ctx}/static/css/zTreeStyle/zTreeStyle.css">
<script type="text/javascript"
	src="${ctx}/static/js/jquery-1.7.1.min.js"></script>
<script src="${ctx}/static/js/jquery.ztree.all-3.5.js"></script>
<script src="${ctx}/static/js/showDiv.js"></script>
<script type="text/javascript" src="${ctx}/static/js/sideBar.js"></script>
<script src="${ctx}/static/js/layer/layer.js"></script>
<script src="${ctx}/static/js/layer/layer-common.js"></script>

</head>
<body>
	<div class="content">
		<div class="right-cot w100">
			<div class="crumbs">
				<p>
					<span class="active ml5"><i class="fa fa-dic"></i> <c:out
							value="${not empty dic.dcId ? '修改字典信息':'新增字典'}"></c:out> </span>
				</p>
				<div class="crumbs-line"></div>
			</div>
			<div class="form-top">
				<div class="mb10">
					<button class="btn btn-blue" onclick="save()" id="saveButton"><i class="fa fa-save"></i> 保 存</button>
				</div>
			</div>
			<div class="table-scroll">

				<input id="s_dcId" type="hidden" value="${dic.dcId}">
				<table class="table-form table-bordered table-tr-td">
					<tbody>
						<tr>
							<td>字典名</td>
							<td colspan="8"><input id="s_dcName" name="dcName"
								class="inputText_sm" value="${dic.dcName}" type="text">
							</td>

						</tr>
						<c:if test="${ not empty dic.dcCode }"> 
						<tr>
							<td>字典编码</td>
							<td colspan="8"><input id="s_dcCode" name="dcCode"
								class="inputText_sm" value="${dic.dcCode}" type="text" readonly="readonly">
							</td>
						</tr>
					</c:if>

						<tr>
							<td>父字典</td>
							<td colspan="8"><input id="s_dcPcode" name="dcPcode"
								class="inputText_sm" value="${dic.dcPcode}"  
								type="hidden" /> <input id="s_pCodeName" name="parentDcName"
								value="${parentDcName}" type="text" /></td>
							
						</tr>
						<tr>
							<td>所属系统</td>

							<td colspan="8"><input id="s_dcSysCode" name="dcSysCode"
								class="inputText_sm" value="${dic.dcSysCode}"  
								type="hidden" /> <input id="s_dcSysName" name="dcSysName"
								value="${dic.dcSysName}" type="text" /></td>
							
						</tr>
						<tr>
							<td>字典状态</td>
							<td colspan="8"><input name="s_dcIsDeleted" value="0"
								type="radio"
								<c:if test="${ '1' ne dic.dcIsDeleted }">checked</c:if>>启用
								<input name="s_dcIsDeleted" value="1" type="radio"
								<c:if test="${'1' eq dic.dcIsDeleted }">checked</c:if>>停用
							</td>
						</tr>
						<tr>
							<td>备注</td>
							<td colspan="8"><input id="s_dcRemark" name="dcRemark"
								class="inputText_sm" value="${dic.dcRemark}" type="text">
							</td>
						</tr>


						<tr>
					</tbody>
				</table>

			</div>
			<div class="block20"></div>

		</div>
		<!--main end-->
	</div>
	<div id="treediv" style='top:75px;left:50px;overflow:scroll;display:none; position:absolute;width:300px;height:200px;background-color:#eeffdd; border:1px solid #BEC0BF;padding:5px;font-size:12px;'>
	<a onclick="hidetreediv();" href="#" class="link-red mr5" style="cursor:pointer;color:red;text-align:right;"><i class="fa fa-close"></i>取消</a>
	<ul id="tree" class="ztree"></ul>
</div>
</body>
<script type="text/javascript">
	function save() {
		var dcName = $("#s_dcName").val();
		var dcCode = $("#s_dcCode").val();
		var dcPcode = $("#s_dcPcode").val();
		var dcId = $("#s_dcId").val();
		var dcRemark = $("#s_dcRemark").val();
		var dcSysCode = $("#s_dcSysCode").val();
		var dcSysName = $("#s_dcSysName").val();
		if (dcName == "") {
			layer.msg('请填写字典名', {
				icon : 0
			});
			return;
		}
		var dcIsDeleted = $("input:radio[name='s_dcIsDeleted']:checked").val();
		var dicType = $("input:radio[name='s_dicType']:checked").val();

		var data = {
			dcId : dcId,
			dcName : dcName,
			dcPcode : dcPcode,
			dcCode : dcCode,
			dcSysCode : dcSysCode,
			dcSysName : dcSysName,
			dcIsDeleted : dcIsDeleted,
			dicType : dicType,
			dcRemark : dcRemark
		};
		$("#saveButton").attr('disabled','disabled');
		$
				.post(
						"${ctx}/dic/save",
						data,
						function(result) {
							if (result.code == "success") {
								layer.msg('操作成功', {
									icon : 1
								});
								window.parent.changePage('${ctx}/dic/list', '#dicQueryForm'
										,'${currentPage}','${pageSize}',0);
								setInterval(
										"parent.layer.close(parent.layer.getFrameIndex(window.name))",
										2000);

							} else {
								layer.msg('未知错误', {
									icon : 2
								});
								$("#saveButton").removeAttr('disabled');
							}
						}, "json");
	}
	var zTreeObj;

	$(document).ready(function() {
		$("#s_pCodeName").focus(function() {
			var divObj = $("#treediv");
			var txtObj = $("#s_pCodeName");
			showDiv(divObj, txtObj, dicsetting, "${ctx}/dic/getDics");
		});
		$("#s_dcSysName").focus(function() {
			var divObj = $("#treediv");
			var txtObj = $("#s_dcSysName");
			showDiv(divObj, txtObj, appsetting, "${ctx}/dic/getsyses");
		});

	});
</script>
</html>